<?php

namespace Common\Model;

class AdminModel extends BaseModel {

  var $adminObj;

  public function __construct($name = '', $tablePrefix = '', $connection = '') {
    parent::__construct($name, $tablePrefix, $connection);
    $this->adminObj = M("Admin");
  }


  /**
   * 查询管理员信息
   * @param array $data 查询条件
   */
  public function adminInfo($data) {
    $adminInfo = $this->adminObj->where($data)->find();
    return $adminInfo;
  }

  /**
   * 查询管理员列表(有分页)
   * @param array $where 搜索条件
   * @return array 列表 分页
   */
  public function adminList($where) {
    $count = $this->adminObj->where($where)->count();
    $Page = new \Think\Page($count, C('LISTNUMBER'));
    $page = $Page->show();
    $list = $this->adminObj->where($where)->order('id desc ')->limit($Page->firstRow . ',' . $Page->listRows)->select();
    return array('list' => $list, 'page' => $page);
  }

}
